import { _decorator, EventTarget } from 'cc';
const { ccclass, property } = _decorator;

import { GameData } from "../Data/GameData";
import { MainState } from "../Data/GameEnum";
import SS_GameManager from "./SS_GameManager";

// /** 事件 */
export const GameEventData = {
    拖拽完成: "拖拽完成",
    广告拉取成功: "广告拉取成功",
    广告拉取失败: "广告拉取失败",
    广告结束: "广告拉取结束",
};

export const eventTarget = new EventTarget();

@ccclass('SS_GameEventManager')
export default class SS_GameEventManager {
    static AddListener() {
        eventTarget.on(GameEventData.拖拽完成, this.On_拖拽完成, this);
    }

    static async On_拖拽完成(msg) {
        SS_GameEventManager.拖拽完成();
    }
    static async 拖拽完成() {
        if (GameData.是否正在消除 === false) {
            GameData.是否正在消除 = true;

            GameData.mainState = MainState.飞;
            SS_GameManager.Instance.Main();
        }
        else {
            GameData.是否等待消除 = true;
        }
    }
}

/** 调试 */
window["SS_GameEventManager"] = SS_GameEventManager;